package cp3120.view;

import cp3120.ucm.UC2ALAdapter;
import cp3120.ucm.client.UCDeleteUser;

import javax.swing.*;
import java.awt.*;

/**
 * Swing Frame that displays a confirmation prompt to delete an account.
 * @author Adam Scarr
 */
public class ConfirmDeleteUI extends JFrame {
    private JPasswordField password;

    /**
     * Class Constructor, Sets up the frame and its components.
     */
    public ConfirmDeleteUI() {
        JTextArea warning = new JTextArea("Please confirm you want to delete your account by typing your password again.");
        //warning.setLineWrap(true);
        add(warning, BorderLayout.NORTH);

        password = new JPasswordField(15);
        add(password, BorderLayout.CENTER);

        JButton delete = new JButton("Delete Me!");
        delete.addActionListener(new UC2ALAdapter(new UCDeleteUser()));
        add(delete, BorderLayout.SOUTH);
        pack();
    }

    /**
     * Returns the string from the password
     * @return
     */
    public String getPassword() {
        return new String(password.getPassword());
    }
}
